Action Bar
Action bar is a container, houses horizontally aligned buttons that enable users to act on single or multiple items.
#Examples
A gray background container bar featuring a single primary action button. Ideal for simple tasks requiring only one action (e.g., "Submit", "Save")
The ActionBar
consists of:
- Container Bar: Provides visual separation with a gray background. This can be removed for a more integrated look by adding the
noBackground
property. - Buttons: Right-aligned buttons are the only controls allowed in an Action Bar. They trigger actions and should be limited to a maximum of 3.
- Primary: The main action (e.g., "Save", "Submit"). Use only once.
- Secondary: Less prominent actions (e.g., "Edit", "Add another").
- Cancel (Default): For neutral actions (e.g., "Cancel", "Close", "Reset")
- Destructive (Red): For irreversible actions (e.g., "Delete").
<ActionBar primary={{ children: "Primary", onClick: console.log }} />
#Loading
Provides visual feedback during action processing by using a spinner to indicate loading, preventing duplicate actions.
const [inProgress, setInProgess] = useState<string | null>(null);
async function handler(action: string) {
setInProgess(action);
await delay(3000);
setInProgess(null);
}
return (
<ActionBar
inProgressAction={inProgress}
primary={{ children: "Primary", onClick: handler }}
secondaries={[{ children: "Secondary", onClick: handler }]}
cancel={{ children: "Cancel", onClick: console.log }}
/>
);
#Links
Navigating users to new tabs or internal pages. Uses primary and secondary buttons for visual distinction. You can use label to indicate if the link opens in a new tab.
<ActionBar
primary={{ children: "Open new tab", href: "https://siteimprove.com", openNew: true }}
secondaries={[{ children: "Navigate in this tab", href: "https://siteimprove.com" }]}
/>
#No padding
Seamlessly integrating the Action Bar with adjacent elements. Useful when the Action Bar needs to blend visually with its surroundings.
<ActionBar primary={{ children: "Primary", onClick: console.log }} noPadding />
#No background
Prioritizing content over the Action Bar background. Employ when the Action Bar needs to be minimally intrusive, allowing the content to take precedence.
<ActionBar primary={{ children: "Primary", onClick: console.log }} noBackground />
Property | Description | Defined | Value |
---|---|---|---|
primaryRequired | object The primary action | ||
secondariesOptional | object[] Possible secondary actions | ||
cancelOptional | object Possible cancellation action | ||
noPaddingOptional | boolean An Action Bar without any padding | ||
noBackgroundOptional | boolean An Action Bar without any background | ||
destructiveOptional | object Possible destructive action, use `DestructiveActionBar` if this is the primary action | ||
inProgressActionOptional | | string A token that identifies if an action is in progress, disabling all actions.
The token is acquired via the onClick handler from each action | ||
data-observe-keyOptional | string Unique string, used by external script e.g. for event tracking | ||
classNameOptional | string Custom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | object Style object to apply custom inline styles (only intended for special cases) |
Property | Description | Defined | Value |
---|---|---|---|
destructiveRequired | object The primary destructive action | ||
cancelRequired | object The alternative cancellation action | ||
inProgressActionOptional | | string A token that identifies if an action is in progress, disabling all actions.
The token is acquired via the onClick handler from each action | ||
data-observe-keyOptional | string Unique string, used by external script e.g. for event tracking | ||
classNameOptional | string Custom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | object Style object to apply custom inline styles (only intended for special cases) |
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications